<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>懒加载2</title>
</head>
<style>
    .box{
        width:100px;
        height:100px;
        background-color:orange;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    };
</style>
<body>
    <div class="box" draggable="true"></div>
    
    <script>
        /*
            getBoundingClientRect
        */ 

        const bnt = document.getElementsByClassName('box')[0];


        console.log(bnt.getBoundingClientRect().top);

        function isInViewWindow(el){
            const viewWidth = window.innerWidth || document.documentElement.clientWidth;
            const viewHeight = window.innerHeight || document.documentElement.clientHeight;

            const {
                top,
            } = el.getBoundingClientRect();
     
            return top < viewHeight;
        }

        console.log(isInViewWindow(bnt));
        
    </script>
</body>
</html>